/*
 * Copyright 2002-2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.beans.factory;

import org.jspecify.annotations.Nullable;

/**
 * Sub-interface implemented by bean factories that can be part
 * of a hierarchy.
 *
 * <p>The corresponding {@code setParentBeanFactory} method for bean
 * factories that allow setting the parent in a configurable
 * fashion can be found in the ConfigurableBeanFactory interface.
 *
 * @author Rod Johnson
 * @author Juergen Hoeller
 * @since 07.07.2003
 * @see org.springframework.beans.factory.config.ConfigurableBeanFactory#setParentBeanFactory
 */
/**
 * HierarchicalBeanFactory接口扩展了BeanFactory接口，提供了层次化 bean 工厂的能力。
 * 这允许在多个bean工厂之间建立父子关系，子bean工厂可以访问父bean工厂中的bean，
 * 但父bean工厂不能访问子bean工厂的bean。这种设计促进了模块化和分层的系统架构，
 * 例如在应用程序的不同层（表示层、业务层、数据层）中分别使用不同的bean工厂。
 */
public interface HierarchicalBeanFactory extends BeanFactory {

	/**
	 * Return the parent bean factory, or {@code null} if there is none.
	 * 获取父Bean工厂，不同的工厂负责不同的工作内容，但是互有联系
	 * 例子：mvc工厂和spring的工厂就是父子关系，想获取一个bean优先从子工厂获取，子工厂没有再去父工厂获取
	 */
	@Nullable BeanFactory getParentBeanFactory();

	/**
	 * 查找当前工厂是否包含这个beanName对应的bean
	 * Return whether the local bean factory contains a bean of the given name,
	 * ignoring beans defined in ancestor contexts.
	 * <p>This is an alternative to {@code containsBean}, ignoring a bean
	 * of the given name from an ancestor bean factory.
	 * @param name the name of the bean to query
	 * @return whether a bean with the given name is defined in the local factory
	 * @see BeanFactory#containsBean
	 */
	boolean containsLocalBean(String name);

}
